<template>
  <section>
    <ym-query-view params="form"
                   :model="form"
                   @search="handlerSearch">
      <el-form inline
               label-position="right"
               label-width="130px">
        <el-form-item label="用户名称">
          <el-input v-model.trim="form.namecode"
                    placeholder="请输入"
                    clearable></el-input>
        </el-form-item>
        <el-form-item label="手机号">
          <el-input v-model.trim="form.登陆手机"
                    placeholder="请输入"
                    clearable></el-input>
        </el-form-item>
        <el-form-item label="状态">
          <el-select v-model.trim="form.nodetype"
                     placeholder="请选择"
                     clearable>
            <el-option v-for="(item,index) in nodetypeOpts"
                       :key="index"
                       :label="item.namecode"
                       :value="item.id"></el-option>
          </el-select>
        </el-form-item>
      </el-form>
    </ym-query-view>
    <list-table :loading="loading"
                :data="data"
                :total='total'
                :filterAnd="filterAnd"
                :currentPage="currentPage"
                :size="size"
                @load="getList"></list-table>
  </section>
</template>
<script>
import { paramsFilter } from '@/utils/params-filter'
import queryMixins from '@/views/mixins/query'
export default {
  mixins: [queryMixins],
  components: {
    listTable: () => import('./component/list-table.vue')
  },
  data () {
    return {
      busiName: "AppUsers",
      nodetypeOpts: [],
    }
  },
  async mounted () {
    this.handlerSearch()
    this.nodetypeOpts = await this.$store.dispatch('options/getOptions', { busiName: this.busiName, rela: 110 })
  },
  methods: {
    handlerSearch (e) {
      this.filterAnd = paramsFilter(this.form, {
        like: ['namecode', '登陆手机'],
      })
      this.currentPage = 1
      if (!e && this.$route.query.page) {
        this.currentPage = Number(this.$route.query.page)
      }
      if (this.$route.query.size) {
        this.perPage = Number(this.$route.query.size)
      }
      this.getList()
    },
    getList (page, size) {
      this.currentPage = page || this.currentPage
      this.size = size || this.size
      this.loading = true
      this.$command.execute({
        api: `/api/SelectByConds/${this.busiName}`,
        params: {
          index: Number(this.currentPage) - 1,
          pageSize: this.size
        },
        data: {
          "CONDS": [].concat(this.filterAnd),
          "ORDER": ['id DESC'],
          "COLUMNS": ["id", "wxopenId", "namecode", "图像", "应用 应用ID", "应用:应用名", "所在区域", "推广人:用户名称", "状态", "用户名称", "登陆手机", "nodetype", "NodeType", 'rela']
        }
      }).then(async res => {
        this.data = res.data
        this.total = await this.$store.dispatch('app/getPageTotal', { busiName: this.busiName, filterAnd: this.filterAnd })

        this.loading = false
      })
    }
  }
}
</script>
